<!--
 * @Author: daidai
 * @Date: 2022-02-28 16:16:42
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-07-20 17:57:11
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\left-center.vue
-->
<template>

  <div style="height: 320px;box-sizing: border-box;position: relative">
    <div style="position: absolute;top:-20px; left: 130px;font-family: 'font1';font-size: 23px;">
      {{title}}
    </div>
    <div style="margin-bottom: 40px"></div>
  <KpiDashboard :data="data"></KpiDashboard>
  </div>
</template>

<script>
import {currentGET} from 'api/modules'

let style = {
  fontSize: 24
}
export default {
  components:{
    KpiDashboard: () => import('@/components/barCom/barIndex.vue')
  },
  props:['data','title'],
  data() {
    return {
      kpiData: [
        {
          id: 1,
          name: '有效新客户等效发展(套餐费)',
          percentage: 53.6,
          current: 60,
          target: 52,
          type: 'pending'
        },
        {
          id: 2,
          name: '有效新客户等效发展(实际进收)',
          percentage: 43.9,
          current: 210,
          target: 268,
          type: 'pending'
        },
        {
          id: 3,
          name: '爱家光网合云电脑',
          percentage: 66,
          current: 40,
          target: 21,
          type: 'completed'
        },
        {
          id: 4,
          name: '有效线盒等效发展',
          percentage: 34,
          current: 30,
          target: 58,
          type: 'pending'
        },
        {
          id: 5,
          name: '其中宽带进收',
          percentage: 22,
          current: 30,
          target: 106,
          type: 'pending'
        },
        {
          id: 6,
          name: '重点产品',
          percentage: 76,
          current: 300,
          target: 95,
          type: 'completed'
        }
      ],
      configs: {
        data: [{
          name: '',
          value: 123,
        },
          {
            name: '',
            value: 67
          },
          {
            name: '',
            value: 123,
          },
          {
            name: '',
            value: 500,
          },
          {
            name: '',
            value: 500,
          },
          {
            name: '',
            value: 500,
          }, {
            name: '',
            value: 1000,
          }]
      },
      options: {},
      userOverview: {
        alarmNum: 0,
        offlineNum: 0,
        onlineNum: 0,
        totalNum: 0,
      },
      pageflag: true,
      timer: null,
      config: {
        number: [100],
        content: '{nt}',
        style: {
          ...style,
          // stroke: "#00fdfa",
          fill: "#00fdfa",
        },
      },
      onlineconfig: {
        number: [0],
        content: '{nt}',
        style: {
          ...style,
          // stroke: "#07f7a8",
          fill: "#07f7a8",
        },
      },
      offlineconfig: {
        number: [0],
        content: '{nt}',
        style: {
          ...style,
          // stroke: "#e3b337",
          fill: "#e3b337",
        },
      },
      laramnumconfig: {
        number: [0],
        content: '{nt}',
        style: {
          ...style,
          // stroke: "#f5023d",
          fill: "#f5023d",
        },
      }

    };
  },
  filters: {
    numsFilter(msg) {
      return msg || 0;
    },
  },
  created() {
    this.getData()
  },
  mounted() {
  },
  beforeDestroy() {
    this.clearData()

  },
  methods: {
    clearData() {
      if (this.timer) {
        clearInterval(this.timer)
        this.timer = null
      }
    },
    getData() {
      this.pageflag = true;
      currentGET("big2").then((res) => {
        if (!this.timer) {
          console.log("设备总览", res);
        }
        if (res.success) {
          this.userOverview = res.data;
          this.onlineconfig = {
            ...this.onlineconfig,
            number: [res.data.onlineNum]
          }
          this.config = {
            ...this.config,
            number: [res.data.totalNum]
          }
          this.offlineconfig = {
            ...this.offlineconfig,
            number: [res.data.offlineNum]
          }
          this.laramnumconfig = {
            ...this.laramnumconfig,
            number: [res.data.alarmNum]
          }
          this.switper()
        } else {
          this.pageflag = false;
          this.$Message.warning(res.msg);
        }
      });
    },
    //轮询
    switper() {
      if (this.timer) {
        return
      }
      let looper = (a) => {
        this.getData()
      };
      this.timer = setInterval(looper, this.$store.state.setting.echartsAutoTime);
    },
  },
};
</script>
<style lang='scss' scoped>
.user_Overview {
  li {
    flex: 1;

    p {
      text-align: center;
      height: 16px;
      font-size: 16px;
    }

    .user_Overview_nums {
      width: 100px;
      height: 100px;
      text-align: center;
      line-height: 100px;
      font-size: 22px;
      margin: 50px auto 30px;
      background-size: cover;
      background-position: center center;
      position: relative;

      &::before {
        content: '';
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
      }

      &.bgdonghua::before {
        animation: rotating 14s linear infinite;
      }
    }

    .allnum {

      // background-image: url("../../assets/img/left_top_lan.png");
      &::before {
        background-image: url("../../assets/img/left_top_lan.png");

      }
    }

    .online {
      &::before {
        background-image: url("../../assets/img/left_top_lv.png");

      }
    }

    .offline {
      &::before {
        background-image: url("../../assets/img/left_top_huang.png");

      }
    }

    .laramnum {
      &::before {
        background-image: url("../../assets/img/left_top_hong.png");

      }
    }
  }
}
</style>